package com.rk.hosp.controller;

import com.rk.common.result.Result;
import com.rk.hosp.service.DepartmentService;
import com.rk.hosp.vo.hosp.DepartmentVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author :Rk.
 * @date : 2022/11/17
 */
@Slf4j
@RestController
@Api(tags = "科室管理接口")
@RequestMapping("/admin/hosp/department")
//@CrossOrigin
public class DepartmentController {

    @Autowired
    private DepartmentService departmentService;

    @ApiOperation(value = "查询科室信息")
    @GetMapping("/getDeptList/{hospcode}")
    public Result findDeptTree(@PathVariable String hospcode) {
        try {
            List<DepartmentVo> deptTree = departmentService.findDeptTree(hospcode);
            return Result.ok(deptTree);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.fail();
        }
    }
}